import { Injectable } from '@angular/core';
import { BaseService } from './base.service';
import { Http, Headers } from '@angular/http';
import { News } from '../domain/news';

@Injectable()
export class NewsService extends BaseService {
    constructor(protected http: Http) {
        super();
    }

    GetNewsList(params?: NewsQueryParameter) {
        let url = "manager/getNews";
        return this.Post<{ count: number, list: News[] }>(url, params);
    }

    GetNewsInfo(newsId: number) {
        let url = "manager/getNewsInfo";
        return this.Post<News>(url, { newsId: newsId });
    }

    SaveNews(news: News) {
        let url = "manager/saveNews";
        return this.Post(url, news);
    }

    DeleteNews(id: number) {
        let url = "manager/delNews";
        return this.Post(url, { newsId: id });
    }

    UploadNewsImage(file: any) {        
        return this.UploadFile(file);
    }
}


export interface NewsQueryParameter {
    title?: string;
    fromDate?: string;
    toDate?: string;
    currentPage: number;
    pageSize: number;
    status?: number
}
